import request from '@/utils/request'

// 查询学员信息列表
export function listBStudent(query) {
  return request({
    url: '/basedata/bstudent/list',
    method: 'get',
    params: query
  })
}

//导出数据
export function exportBStudent(query) {
  return request({
    url: '/basedata/bstudent/export',
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

// 查询学员详细
export function getBStudent(bstudentId) {
  return request({
    url: '/basedata/bstudent/' + bstudentId,
    method: 'get'
  })
}

//根据学号查询学员详细
export function getBStudentByNo(bstudentNo) {
  return request({
    url: '/basedata/bstudent/getStuByNo/' + bstudentNo,
    method: 'get'
  })
}

// 恢复学员信息
export function restoreStudent(data) {
  //that.$refs.uploadxls.submit() // 提交时触发了before-upload函数
  return request({
    url: '/basedata/bstudent/restore',
    method: 'post',
    data: data
  })
}

// 新增学员信息
export function addBStudent(data) {
  //that.$refs.uploadxls.submit() // 提交时触发了before-upload函数
  return request({
    url: '/basedata/bstudent/create',
    method: 'post',
    data: data
  })
}

// 修改学员信息
export function updateBStudent(id, data) {
  return request({
    url: '/basedata/bstudent/update/' + id,
    method: 'put',
    data: data
  })
}

// 删除学员信息
export function delBStudent(id) {
  return request({
    url: '/basedata/bstudent/deleteByIds/' + id,
    method: 'delete'
  })
}

// // 导出学员信息
// export function exportBStudent(query) {
//   return request({
//     url: '/basedata/bstudent/export',
//     method: 'get',
//     params: query
//   })
// }

// 获取字典选择框列表
export function optionselect() {
  return request({
    url: '/basedata/dict/optionselect',
    method: 'get'
  })
}

// 学员状态修改
export function changeBStudentStatus(bstudentId, status) {
  const params = {
    status
  }
  return request({
    url: '/basedata/bstudent/update/status/' + bstudentId,
    method: 'put',
    params: params
  })
}

// 下载学员信息导入模板
export function importTemplate() {
  return request({
    url: '/basedata/bstudent/importTemplate',
    responseType: 'blob',
    method: 'get'
  })
}

// 根据班级查询对应的寄宿学员列表
export function getStuInfoByClassId(classId) {
  return request({
    url: '/basedata/bstudent/getStuInfoByClassId/' + classId,
    method: 'get'
  })
}
//分班
export function assignClass(data) {
  return request({
    url: '/basedata/bstudent/assign/class',
    method: 'put',
    data: data
  })
}
//分宿舍
export function assignDrom(data) {
  return request({
    url: '/basedata/bstudent/assign/dorm',
    method: 'put',
    data: data
  })
}

// 宿舍列表
export function getBdormitoryListAll() {
  return request({
    url: '/basedata/bdormitory/getAllDormitory',
    method: 'get'
  })
}


// 查询床号
export function getDormitoryBedList(dormitoryId) {
  return request({
    url: `/basedata/bdormitory/getDormitoryBedList/${dormitoryId}`,
    method: 'get'
  })
}


// 提交床位
export function allocateDormitoryAndBed(data) {
  return request({
    url: '/basedata/bdormitory/allocateDormitoryAndBed',
    method: 'put',
    data
  })
}


export function submitDormitoryAndBed(data) {
  return request({
    url: '/basedata/bstudent/allocateDormitoryAndBed',
    method: 'post',
    data
  })
}

export function addFaceInfo(data) {
  console.log("addFaceInfo() data:",data)
  return request.post('/basedata/bstudent/addFaceInfo',data)
}

export function syncPhotoToAccessControl(data){
  return request({
    url: '/basedata/bstudent/syncPhotoToAccessControl',
    method: 'post',
    data
  })
}

export function syncPhotoToAttendance(data){
  return request({
    url: '/basedata/bstudent/syncPhotoToAttendance',
    method: 'post',
    data
  })
}
export function resetPwd(id){
  return request({
    url: '/basedata/bstudent/resetPwd/' + id,
    method: 'put'
  })
}

